﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Channels;

namespace suanpan.API.Components.Channels.HLRest
{
    class HLBindingElement: BindingElement
    {

        public HLBindingElement() { }
        public HLBindingElement(HLBindingElement bindingElement) { }
       
        public override BindingElement Clone()
        {
            return new HLBindingElement(this);
        }

        public override T GetProperty<T>(BindingContext context)
        {
            return context.GetInnerProperty<T>();
        }
        public override IChannelListener<TChannel> BuildChannelListener<TChannel>(BindingContext context)
        {

            HLChannelListener channelListener = new HLChannelListener(context);
            return (IChannelListener<TChannel>)channelListener;
        }
        public override bool CanBuildChannelListener<TChannel>(BindingContext context)
        {
            if (context == null)
                throw new ArgumentNullException("Context missing");

            if (typeof(TChannel) == typeof(IReplyChannel))
                return context.CanBuildInnerChannelListener<TChannel>();
            else
                return false;
        }
    }
}
